// 验收/标准巡检 项的设置界面
import ByCol from "@/components/ui/ByCol";
import ByRow from "@/components/ui/ByRow";
import ByTag from "@/components/ui/ByTag";
import ByCell from "@/components/ui/ByCell";
import ByImageGroup from "@/components/ui/ByImageGroup";

import { Text, View } from "@tarojs/components";

const cellProps = {
  border: true,
  labelWidth: "5em",
};

export default ({ source, index }) => {
  const { quesRemark, options, picList } = source;

  const option = options.find((e) => e.isCheck);

  return (
    <View>
      <ByRow className="py-3 border-b-1 border-line-light">
        <ByCol span={"auto"}>
          <Text>{index}.</Text>
          <Text>{source.quesName}</Text>
        </ByCol>

        {option ? (
          <ByTag size="small" type={option.isQualified ? "success" : "error"}>
            {option.optionsName}
          </ByTag>
        ) : (
          <ByTag size="small" type="info">
            未验收
          </ByTag>
        )}
      </ByRow>

      {quesRemark && (
        <ByCell label="备注" {...cellProps}>
          {quesRemark}
        </ByCell>
      )}

      {picList && (
        <ByCell label="照片" vertical {...cellProps}>
          <ByImageGroup urls={picList} />
        </ByCell>
      )}
    </View>
  );
};
